Skip to content

Reshard form: discover all destination shards and known external stores#921

Merged
benben merged 1 commit into
mainfrom
ben/reshard-target-discovery
Jul 9, 2026
Merged

Reshard form: discover all destination shards and known external stores#921
benben merged 1 commit into
mainfrom
ben/reshard-target-discovery

Conversation

@benben

@benben benben commented Jul 9, 2026

Copy link
Copy Markdown
Member

The reshard form's shard dropdown was derived from duckling statuses — i.e. the shards tenants already occupy — so a freshly stood-up empty shard (mw-dev's new shard-002) never appeared, which is exactly the shard a rebalancing reshard wants to target.

New GET /reshards/targets

  • cnpg shards: discovered from the CNPG instance pods (cnpg.io/cluster label, cnpg-shards namespace) via the same cluster-topology pod read the Nodes view already uses — includes empty shards, no new RBAC. An RBAC Forbidden (the e2e CP's SA) degrades to the occupied-shard fallback with cluster_discovery: false, so the UI can explain why a brand-new shard would need manual entry there.
  • external stores: distinct external metadata stores referenced by live (non-deleted) warehouses — endpoint + SM secret name + user/db, never a password — offered as prefill options for the cnpg→external escape hatch.

UI

Shard dropdown fed by the endpoint (unioned with occupied shards as a belt-and-suspenders fallback; free-text "other…" stays), a notice when discovery is degraded, and a "Known external stores" prefill select on the external target form. The password field remains manual, always.

Tests

  • admin/reshard_test.go: cluster discovery surfaces an empty shard + unions occupied ones; Forbidden and nil-client degrade paths; external stores present.
  • tests/configstore/reshard_postgres_test.go: ListExternalMetadataStores distinct/live-only/field mapping.
  • e2e: new reshard_targets assertion — occupied-shard fallback contains the cnpg org's shard, the ext org's RDS appears as a known external store, and the response never carries a password field. Verifies the degrade path for real (the e2e CP has no cluster RBAC).
  • UI: npm run build + vitest green.

On a real deployment (mw-dev/prod CPs have the cluster-topology ClusterRole) the dropdown now shows shard-002 the moment its pods exist — no tenant required.

🤖 Generated with Claude Code

The form's shard dropdown was derived from duckling statuses — the
shards tenants already OCCUPY — so a freshly created empty shard
(mw-dev shard-002) never appeared, exactly the shard a rebalancing
reshard wants to target.

New GET /reshards/targets: cnpg shards discovered from the CNPG
instance pods (label cnpg.io/cluster, cnpg-shards namespace) via the
same cluster-topology read the Nodes view uses — includes EMPTY shards;
an RBAC Forbidden (the e2e CP) degrades to the occupied-shard fallback
with cluster_discovery=false so the form can say why a new shard needs
manual entry. Plus known external stores: distinct external metadata
stores of live warehouses (endpoint + SM secret NAME + user/db — never
a password), offered as prefill for the cnpg->ext escape hatch.

UI: shard dropdown fed by the endpoint (unioned with occupied shards as
fallback), a degrade notice, and a known-external-stores prefill select;
the password stays manual always.
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Test Impact Plan

Deterministic summary of how this PR changes tests, CI runners, and coverage-risk signals.

Summary

Area Added Changed Deleted
Test files 0 3 0
E2E/journey files 0 1 0
Workflow files 0 0 0

Signals

  • Test cases: +3 / -0
  • Assertions: +19 / -0
  • Skips or known failures added: 0
  • Workflow continue-on-error added: 0
  • Workflow path filters added: 0
  • Test commands removed from justfile: 0
  • E2E/journey retry lines added: 0

Coverage risk: needs review

Warnings

  • E2E or journey files changed (needs review)
    • tests/e2e-mw-dev/harness.sh

@benben benben merged commit 03eeee6 into main Jul 9, 2026
26 checks passed
@benben benben deleted the ben/reshard-target-discovery branch July 9, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant